import {_axios as axios} from '@/libs/request'
/**
 * 添加用户*/
export const addUserByAdmin = (data) => {
    return axios({
        url: 'user/admin/addUser',
        data,
        // skipDefaultErrorHandling:false
    })
}
//获取用户列表
export const getUserList = (data) => {
    return axios({
        url: 'user/getUserList',
        data,
        // skipDefaultErrorHandling:false
    })
}
/**
 * 根据用户id删除用户
* @Param {string|string[]} id - 要删除的用户id*/
export const deleteUserById= (id) => {
    return axios({
        url: 'user/deleteUserById',
        data: {id},
        // skipDefaultErrorHandling:false
    })
}

/**
 * 获取角色列表*/
export const getRoleList = (data) => {
    return axios({
        url: 'role/getRoleList',
        data,
        // skipDefaultErrorHandling:false
    })
}

/**
 * 添加角色*/
export const addRole= (data) => {
    return axios({
        url: 'role/addRole',
        data,
        // skipDefaultErrorHandling:false
    })
}
/**
 * 删除角色
 * @Param {string|string[]} id - 要删除的角色id*/
export const deleteRoleById= (id) => {
    return axios({
        url: 'role/deleteRoleById',
        data: {id},
        // skipDefaultErrorHandling:false
    })
}

/**
 * 根据roleId获取用户列表*/
export const getUserByRoleId= (id) => {
    return axios({
        url: 'user/getUserByRoleId',
        data: {id},
    })
}

/**
 * 为角色分配用户*/
export const addUserToRole= (data) => {
    return axios({
        url: 'role/addUserToRole',
        data,
    })
}
/**
 * 为角色分配权限*/
export const addPermissionToRole= (data) => {
    return axios({
        url: 'role/addPermissionToRole',
        data,
    })
}
/**
 * 添加路由*/
export const createRoute= (data) => {
    return axios({
        url: 'permission/createRoute',
        data,
        skipDefaultMsg:false
    })
}

/**
 * 获取路由*/
export const getRoutes= (data) => {
    return axios({
        url: 'permission/getRoutes',
        data,
    })
}
/**
 * 根据角色id，获取全部权限列表，并在列表中标记该角色的权限 */
export const getRoutesByRoleId=  (roleId) => {
    return axios({
        url: 'permission/getRoutesByRoleId',
        data: {roleId},
    })
}
/**
 * 根据用户id，获取所拥有的路由*/
export const getRoutesByUserId=  (userId) => {
    return axios({
        url: 'permission/getRoutesByUserId',
        data: {userId},
    })
}
/**
 * 删除菜单及其后代节点*/
export const deleteRouteWithChildren=  (id) => {
    return axios({
        url: 'permission/deleteWithChildren',
        data: {id},
    })
}